﻿using System;
using System.Data;
using System.Web;
using System.Web.UI.WebControls;
using Texfina.Core.Common;  
using Texfina.Core.Web;
using Texfina.Core.Data;  
using Texfina.Entity.Rh;
using RHBOQry = Texfina.BOQry.Rh;

namespace RH
{
   public partial class AFPBnd : SearchPage 
   {
      protected void Page_Load(object sender, EventArgs e)
      {
                       
         this.LoadInitialSettings();
         if(this.IsPostBack){
            this.LoadInPostBack();
            return;
         } 

         this.LoadData();
         SearchData();

      }

      public override void LoadInitialSettings()
      {
         Label lbl = (Label) this.Master.FindControl("lblTitle");
         lbl.Text = "AFP";
         this.Page.Form.DefaultButton = bttSearch.UniqueID;
      }

      public override void SearchData()
      {

         EAfpBandeja objE = new EAfpBandeja();

         if (this.txtidAfp.Text == "")
            objE.IdAfp = null;
         else
             objE.IdAfp = this.txtidAfp.Text;

          if (this.txtdsAfp.Text == "")
            objE.DsAfp = null;
         else
             objE.DsAfp = this.txtdsAfp.Text; 

         IBOQuery objBO = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(RHBOQry.Afp));
         DataTable dt = objBO.GetByCriteria(objE);

         this.GridSetDataBinding(grdList, dt);

      }

      protected void mnuToolbar_MenuItemClick(Object sender, MenuEventArgs e)
      {
          String strQS= "";

         switch(e.Item.Value){
            case ConstMenuToolbarValue.BUTTON_NEW:
               strQS = "wfAfpMnt.aspx?formEA=" + Convert.ToInt32(FormEditAction.AddNew).ToString() + "&IdAfp=";
               break; 
         }
         Response.Redirect(strQS);
      }

      protected void grdList_RowCommand(Object sender, GridViewCommandEventArgs e)
      { 
         DataRow dr = this.GridGetRowFromDataKey(grdList, Convert.ToInt32(e.CommandArgument));
         FormEditAction formEA= FormEditAction.AddNew;

         switch(e.CommandName)
         {
             case ConstGridRowCommand.GRIDEDIT:
               formEA = FormEditAction.Edit;
               break;
             case ConstGridRowCommand.GRIDDELETE:
               formEA = FormEditAction.Delete;
               break;
             case ConstGridRowCommand.GRIDPREVIEW:
               //this.PrintReport(Convert.ToInt32(e.CommandArgument));
               return;
         }
         String strQS = "wfAFPMnt.aspx?formEA=" + Convert.ToInt32(formEA).ToString() + "&IdAfp=" + dr["idAfp"].ToString();
         Response.Redirect(strQS);
      
      }
      
       protected void bttOk_Click(object sender, EventArgs e)
      {
          this.SearchData();
      }
   }
}